<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>



<f:subview id="users">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">
		<script type="text/javascript">
			var row;
		</script>
		<a4j:region>
			<rich:dataTable value="#{userManager.dataList}" var="dataItem"
				reRender="ds" id="usersList"
				onRowContextMenu="row=this; alert(this);"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" border="0" rows="20">

				<f:facet name="header">
					<h:outputText value="#{msg['kurier.uzytkownicy']}" />
				</f:facet>

				<rich:column width="25" sortBy="#{dataItem.id}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.klienci.idUzytk']}" />
					</f:facet>
					<h:outputText value="#{dataItem.id}" />
				</rich:column>

				<rich:column width="25" sortBy="#{dataItem.login}"
					filterBy="#{dataItem.login}" filterEvent="onkeyup">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.login']}" />
					</f:facet>
					<h:outputText value="#{dataItem.login}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.haslo}}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.haslo']}" />
					</f:facet>
					<h:outputText value="#{dataItem.haslo}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.mail}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.mail']}" />
					</f:facet>
					<h:outputText value="#{dataItem.mail}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.rodzaj}"
					filterBy="#{dataItem.rodzaj}" filterEvent="onkeyup">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.rodzaj.uzytkownika']}" />
					</f:facet>
					<h:outputText id="imieOutput" value="#{dataItem.rodzaj}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.dataRej}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.data.rejestracji']}" />
					</f:facet>
					<h:outputText value="#{dataItem.dataRej}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.dataOstatLog}">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.data.ostatniego.logowania']}" />
					</f:facet>

					<h:outputText value="#{dataItem.dataOstatLog}" />

				</rich:column>



				<rich:column>
					<a4j:commandLink ajaxSingle="true" id="editlink"
						reRender="editMPusers" action="#{userManager.prepareEditData}"
						oncomplete="#{rich:component('editMPusers')}.show()">
						<h:graphicImage value="/images/edit.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{userManager.editedData}" />
					</a4j:commandLink>
					<rich:toolTip for="editlink" value="#{msg['kurier.zlec.edit']}" />

					<a4j:commandLink ajaxSingle="true" id="deleteLink"
						oncomplete="#{rich:component('deleteMPusers')}.show()">
						<h:graphicImage value="/images/delete.gif" style="border:0" />
						<f:setPropertyActionListener value="#{dataItem}"
							target="#{userManager.editedData}" />
					</a4j:commandLink>
					<rich:toolTip for="deleteLink" value="#{msg['kurier.zlec.usun']}" />
				</rich:column>

				<f:facet name="footer">
					<rich:datascroller id="ds" align="center" for="usersList"
						maxPages="20" />
				</f:facet>
			</rich:dataTable>
			<a4j:commandButton styleClass="RFbutton"
				value="#{msg['kurier.zlec.dodaj']}"
				action="#{userManager.prepareAddData}"
				reRender="usersList, addMPusers"
				oncomplete="#{rich:component('addMPusers')}.show()">
			</a4j:commandButton>
			<a4j:commandButton styleClass="RFbutton"
				value="#{msg['kurier.zlec.odswierz']}"
				action="#{userManager.refreshData}" reRender=" usersList">
			</a4j:commandButton>
			<rich:messages id="mymessages" globalOnly="true" style="color:red" />
		</a4j:region>
	</h:form>


	<rich:modalPanel id="editMPusers" domElementAttachment="parent"
		autosized="true" width="500" height="350">

		<f:facet name="header">
			<h:outputText id="editLabel" value="#{msg['kurier.zlec.edit']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="hidelink" />
				<rich:componentControl for="editMPusers" attachTo="hidelink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>

			<a4j:outputPanel ajaxRendered="true">
				<h:panelGrid columns="3" border="0">

					<h:column>
						<h:outputLabel for="login" value="#{msg['kurier.login']}:" />
					</h:column>
					<h:column>
						<h:inputText size="35" id="login"
							value="#{userManager.editedData.login}" immediate="true"
							required="true" maxlength="70" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="login" />
					</h:column>

					<h:column>
						<h:outputLabel for="haslo" value="#{msg['kurier.haslo']}:" />
					</h:column>
					<h:column>
						<h:inputText size="35" id="haslo"
							value="#{userManager.editedData.haslo}" immediate="true"
							required="true" maxlength="120" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="haslo" />
					</h:column>

					<h:column>
						<h:outputLabel for="mail" value="#{msg['kurier.mail']}:" />
					</h:column>
					<h:column>
						<h:inputText size="35" id="mail"
							value="#{userManager.editedData.mail}" immediate="true"
							required="true" validator="#{userManager.emailValidate}" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="mail" />
					</h:column>

					<h:column>
						<h:outputLabel for="rodzaj"
							value="#{msg['kurier.rodzaj.uzytkownika']}:" />
					</h:column>
					<h:column>
						<h:selectOneMenu id="rodzaj"
							value="#{userManager.editedData.rodzaj}" immediate="true">
							<f:selectItems value="#{userManager.rodzajList}" />

						</h:selectOneMenu>
					</h:column>
					<h:column>
						<h:message style="color:red" for="rodzaj" />
					</h:column>


					<h:column>
						<h:outputLabel for="dataRej"
							value="#{msg['kurier.data.rejestracji']}:" />
					</h:column>
					<h:column>
						<rich:calendar id="dataRej"
							value="#{userManager.editedData.dataRej}"
							locale="#{userManager.calendar.locale}"
							popup="#{userManager.calendar.popup}" immediate="true"
							datePattern="#{userManager.calendar.pattern}" cellWidth="24px"
							cellHeight="22px" style="width:200px" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="dataRej" />
					</h:column>

					<h:column>
						<h:outputLabel for="dataOstLog"
							value="#{msg['kurier.data.ostatniego.logowania']}:" />
					</h:column>
					<h:column>
						<rich:calendar id="dataOstLog"
							value="#{userManager.editedData.dataOstatLog}"
							locale="#{userManager.calendar.locale}"
							popup="#{userManager.calendar.popup}" immediate="true"
							datePattern="#{userManager.calendar.pattern}" cellWidth="24px"
							cellHeight="22px" style="width:200px" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="dataOstLog" />
					</h:column>



					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{userManager.editData}" reRender=" usersList"
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editMPusers')}.hide();}">
					</a4j:commandButton>
					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.anuluj']}"
						onclick="#{rich:component('editMPusers')}.hide(); return false;" />

				</h:panelGrid>
				<rich:messages id="mymessages" globalOnly="true" style="color:red" />
			</a4j:outputPanel>

		</h:form>

	</rich:modalPanel>

	<rich:modalPanel id="addMPusers"
		autosized="true" width="500" height="350">
		<f:facet name="header">
			<h:outputText id="addLabel" value="#{msg['kurier.zlec.dodaj']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="hidelink1" />
				<rich:componentControl for="addMPusers" attachTo="hidelink1"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<a4j:outputPanel  ajaxRendered="true">
				<h:panelGrid columns="3" border="0">


					<h:column>
						<h:outputLabel for="login" value="#{msg['kurier.login']}:" />
					</h:column>
					<h:column>
						<h:inputText size="35" id="login"
							value="#{userManager.newData.login}" required="true" immediate="true"
							maxlength="70" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="login" />
					</h:column>

					<h:column>
						<h:outputLabel for="haslo" value="#{msg['kurier.haslo']}:" />
					</h:column>
					<h:column>
						<h:inputSecret size="35" id="haslo"
							value="#{userManager.newData.haslo}" required="true" immediate="true"
							maxlength="120" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="haslo" />
					</h:column>

					<h:column>
						<h:outputLabel for="mail" value="#{msg['kurier.mail']}:" />
					</h:column>
					<h:column>
						<h:inputText size="35" id="mail"
							value="#{userManager.newData.mail}" required="true"  immediate="true"
							validator="#{userManager.emailValidate}" />
					</h:column>
					<h:column>
						<h:message style="color:red" for="mail" />
					</h:column>

					<h:column>
						<h:outputLabel for="rodzaj"
							value="#{msg['kurier.rodzaj.uzytkownika']}:" />
					</h:column>
					<h:column>
						<h:selectOneMenu id="rodzaj" value="#{userManager.newData.rodzaj}" immediate="true">
							<f:selectItems value="#{userManager.rodzajList}" />

						</h:selectOneMenu>
					</h:column>
					<h:column>
						<h:message style="color:red" for="rodzaj" />
					</h:column>


					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{userManager.addData}" 
						reRender="usersList"
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('addMPusers')}.hide();}"/>
					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.anuluj']}"
						onclick="#{rich:component('addMPusers')}.hide(); return false;" />
				</h:panelGrid>
				<rich:messages id="mymessages" globalOnly="true" style="color:red" />
			</a4j:outputPanel>

		</h:form>
	</rich:modalPanel>

	<rich:modalPanel id="deleteMPusers" autosized="true" width="200">
		<f:facet name="header">
			<h:outputText value="#{msg['kurier.zlec.usun']}"
				style="padding-right:15px;" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/close2.png" styleClass="hidelink"
					id="hidelink2" />
				<rich:componentControl for="deleteMPusers" attachTo="hidelink2"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<table width="100%">
				<tbody>
					<tr>
						<td align="center" width="50%"><a4j:commandButton
								styleClass="RFbutton" value="#{msg['kurier.zlec.tak']}"
								ajaxSingle="true" action="#{userManager.deleteData}"
								oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('deleteMPusers')}.hide();}"
								reRender="usersList" /></td>
						<td align="center" width="50%"><a4j:commandButton
								styleClass="RFbutton" value="#{msg['kurier.zlec.edit.anuluj']}"
								onclick="#{rich:component('deleteMPusers')}.hide();return false;" />
						</td>
					</tr>
				</tbody>
			</table>
			<rich:messages id="mymessages" globalOnly="true" style="color:red" />
		</h:form>
	</rich:modalPanel>
	<a4j:status onstart="#{rich:component('wait')}.show()"
		onstop="#{rich:component('wait')}.hide()" />
	<rich:modalPanel id="wait" autosized="true" width="200" height="120"
		moveable="false" resizeable="false">
		<f:facet name="header">
			<h:outputText value="Processing" />
		</f:facet>
		<h:outputText value="Wait Please..." />
	</rich:modalPanel>




</f:subview>
